package com.eastshop.address.dao;

import java.util.List;

import org.hibernate.hql.ast.HqlASTFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.eastshop.address.vo.Address;
/**
 * 收货地址的Dao类
 * @author admin
 *
 */
public class AddressDao extends HibernateDaoSupport{
	// Dao层根据用户的id查询收货地址
	public List<Address> findByUid(Integer uid) {
		String hql = "from Address a where a.user.uid = ?";
		List<Address> list = this.getHibernateTemplate().find(hql, uid);
		if(list !=null && list.size() > 0){
			return list;
		}
		return null;
	}

	// Dao层保存收货地址的方法
	public void save(Address address) {
		this.getHibernateTemplate().save(address);
	}

	// Dao层根据收货地址id查找收货地址
	public Address findByAid(Integer aid) {
		Address address = this.getHibernateTemplate().get(Address.class, aid);
		return address;
	}
	
	// Dao层更新收货地址
	public void update(Address address) {
		this.getHibernateTemplate().update(address);
	}

	// Dao层删除收货地址
	public void delete(Address address) {
		this.getHibernateTemplate().delete(address);
	}
	
}
